
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>因子计算 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="已支持的表.html" />
    
    
    <link rel="prev" href="函数及常量.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="快速使用.html">
            
                <a href="快速使用.html">
            
                    
                    快速使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="函数及常量.html">
            
                <a href="函数及常量.html">
            
                    
                    函数及常量
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4" data-path="BARRA因子.html">
            
                <a href="BARRA因子.html">
            
                    
                    因子计算
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="已支持的表.html">
            
                <a href="已支持的表.html">
            
                    
                    已支持的表
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="balance_sheet.html">
            
                <a href="balance_sheet.html">
            
                    
                    balance_sheet
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="deriv_finance_indicator.html">
            
                <a href="deriv_finance_indicator.html">
            
                    
                    deriv_finance_indicator
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="fundamentals_balance.html">
            
                <a href="fundamentals_balance.html">
            
                    
                    fundamentals_balance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="fundamentals_cashflow.html">
            
                <a href="fundamentals_cashflow.html">
            
                    
                    fundamentals_cashflow
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="fundamentals_income.html">
            
                <a href="fundamentals_income.html">
            
                    
                    fundamentals_income
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="share_change.html">
            
                <a href="share_change.html">
            
                    
                    share_change
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="trading_derivative_indicator.html">
            
                <a href="trading_derivative_indicator.html">
            
                    
                    trading_derivative_indicator
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="项目说明.html">
            
                <a href="项目说明.html">
            
                    
                    项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    参与项目开发
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="参与项目开发/添加函数.html">
            
                <a href="参与项目开发/添加函数.html">
            
                    
                    添加函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="参与项目开发/添加数据表.html">
            
                <a href="参与项目开发/添加数据表.html">
            
                    
                    添加数据表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >因子计算</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="barra-factor">BARRA Factor</h1>
<p>Quant Share&#x4E2D;&#x5185;&#x7F6E;&#x4E86;&#x90E8;&#x5206;&#x56E0;&#x5B50;&#x7684;&#x8BA1;&#x7B97;&#xFF0C;&#x4F4D;&#x4E8E;&#x6A21;&#x5757;<code>FactorCalc</code>&#x4E2D;&#x3002;&#x76EE;&#x524D;&#x6682;&#x4E0D;&#x652F;&#x6301;&#x4F20;&#x5165;&#x5916;&#x754C;&#x6570;&#x636E;&#xFF0C;&#x73B0;&#x6570;&#x636E;&#x8FDB;&#x6765;&#x81EA;&#x4E8E;Quant Share&#x672C;&#x5730;&#x7684;&#x6570;&#x636E;&#x3002;&#x540E;&#x7EED;&#x4F1A;&#x8003;&#x8651;&#x63A5;&#x5165;&#x7528;&#x6237;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<h2 id="&#x56E0;&#x5B50;&#x6A21;&#x677F;factorbase">&#x56E0;&#x5B50;&#x6A21;&#x677F;<code>FactorBase</code></h2>
<p>&#x540E;&#x7EED;&#x6240;&#x6709;&#x56E0;&#x5B50;&#x7C7B;&#x57FA;&#x4E8E;&#x8BE5;&#x7C7B;&#x521B;&#x5EFA;&#x3002;&#x9700;&#x4F20;&#x5165;beginDate&#x548C;endDate&#xFF0C;&#x65E5;&#x671F;&#x683C;&#x5F0F;&#x4E3A;<code>%Y%m%d</code></p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, beginDate: str = None, endDate: str = None, **kwargs)</span> -&gt; <span class="hljs-keyword">None</span>:</span>
</code></pre>
<h3 id="regress"><code>regress</code></h3>
<p>&#x56DE;&#x5F52;&#x51FD;&#x6570;&#xFF0C;&#x53EF;&#x8FDB;&#x884C;&#x5E26;&#x6743;&#x91CD;&#x7684;&#x56DE;&#x5F52;&#xFF0C;&#x9ED8;&#x8BA4;&#x5FFD;&#x7565;&#x65E0;&#x6548;&#x503C;&#x3002;</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">regress</span><span class="hljs-params">(y, X, intercept: bool = True, weight: int = <span class="hljs-number">1</span>, verbose: bool = True)</span>:</span>
    <span class="hljs-string">&apos;&apos;&apos;
    :param y: &#x56E0;&#x53D8;&#x91CF;
    :param X: &#x81EA;&#x53D8;&#x91CF;
    :param intercept: &#x662F;&#x5426;&#x6709;&#x622A;&#x8DDD;
    :param weight: &#x6743;&#x91CD;
    :param verbose: &#x662F;&#x5426;&#x8FD4;&#x56DE;&#x6B8B;&#x5DEE;
    :return:
    &apos;&apos;&apos;</span>
</code></pre>
<h3 id="aligndata"><code>align_data</code></h3>
<p>&#x57FA;&#x4E8E;index&#x548C;columns&#x8FDB;&#x884C;&#x8868;&#x683C;&#x7684;&#x5BF9;&#x9F50;&#x3002;&#x4F20;&#x5165;&#x5F62;&#x5F0F;&#x53EF;&#x4E3A;<code>align_data([df1, df2], df3, df4)</code></p>
<pre><code class="lang-python"> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">align_data</span><span class="hljs-params">(self, data_lst: list[pd.DataFrame] = [], *args)</span>:</span>
    <span class="hljs-string">&apos;&apos;&apos;
    &#x57FA;&#x4E8E;index&#x548C;columns&#x8FDB;&#x884C;&#x8868;&#x683C;&#x7684;&#x5BF9;&#x9F50;
    :param data_lst: &#x4EE5;&#x5217;&#x8868;&#x5F62;&#x5F0F;&#x4F20;&#x5165;&#x9700;&#x8981;&#x5BF9;&#x9F50;&#x7684;&#x8868;&#x683C;
    :param args: &#x53EF;&#x4EE5;&#x4F20;&#x5165;&#x5355;&#x4E2A;&#x8868;&#x683C;
    :return: 
    &apos;&apos;&apos;</span>
</code></pre>
<h3 id="winsorize"><code>winsorize</code></h3>
<p>&#x5BF9;&#x79BB;&#x7FA4;&#x503C;&#x8FDB;&#x884C;&#x622A;&#x65AD;&#x3002;&#x6709;<code>mad</code>&#x548C;<code>tile</code>&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x3002;</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">winsorize</span><span class="hljs-params">(
    series: pd.Series or np.ndarray,
    n: float or int = <span class="hljs-number">3</span>,
    mode: str = <span class="hljs-string">&apos;mad&apos;</span>,
    **kwargs
    )</span>:</span>
    <span class="hljs-string">&apos;&apos;&apos;
    :param series: 
    :param n: &#x8003;&#x8651;&#x79BB;&#x7FA4;&#x503C;&#x7684;&#x8303;&#x56F4;&#xFF0C;&#x9ED8;&#x8BA4;&#x4E3A;3&#xFF0C;&#x5BF9;mad&#x65B9;&#x6CD5;&#x751F;&#x6548;
    :param mode: &#x63A7;&#x5236;&#x622A;&#x65AD;&#x65B9;&#x5F0F;&#xFF0C;&#x6709;mad&#x548C;tile&#x4E24;&#x79CD;&#x65B9;&#x6CD5;
    :param kwargs: &#x53EF;&#x4F20;&#x5165;limits &#xFF08;eg. [0.1,0.1]&#xFF09;,&#x5BF9;tile&#x65B9;&#x6CD5;&#x751F;&#x6548;
    :return: 
    &apos;&apos;&apos;</span>
</code></pre>
<h3 id="nomalizezscore"><code>nomalize_zscore</code></h3>
<p>&#x4E2D;&#x503C;&#x5316;&#xFF0C;&#x91C7;&#x7528;Z-score&#x7684;&#x5F62;&#x5F0F;&#x3002;</p>
<p>$$
    x&apos;=\frac{X-\mu}{\sigma}</p>
<p>$$</p>
<h3 id="backtest"><code>BackTest</code></h3>
<p>&#x5BF9;&#x5BBD;&#x8868;&#x5F62;&#x5F0F;&#x7684;&#x56E0;&#x5B50;&#x8FDB;&#x884C;&#x7B80;&#x5355;&#x56DE;&#x6D4B;&#xFF0C;&#x56DE;&#x6D4B;&#x91C7;&#x7528;Quant Share&#x5185;&#x7F6E;&#x7684;DataClass&#x4F5C;&#x4E3A;&#x57FA;&#x51C6;&#xFF0C;&#x91C7;&#x7528;simpleBT&#x8FDB;&#x884C;&#x56DE;&#x6D4B;&#x3002;</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">BackTest</span><span class="hljs-params">(self, data: pd.DataFrame, DataClass=None)</span>:</span>
</code></pre>
<h2 id="sizefactor"><code>SizeFactor</code></h2>
<p>&#x89C4;&#x6A21;&#x56E0;&#x5B50;&#x3002;</p>
<h2 id="liquidity"><code>Liquidity</code></h2>
<p>&#x6D41;&#x52A8;&#x6027;&#x56E0;&#x5B50;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="函数及常量.html" class="navigation navigation-prev " aria-label="Previous page: 函数及常量">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="已支持的表.html" class="navigation navigation-next " aria-label="Next page: 已支持的表">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"因子计算","level":"1.4","depth":1,"next":{"title":"已支持的表","level":"1.5","depth":1,"path":"已支持的表.md","ref":"已支持的表.md","articles":[{"title":"balance_sheet","level":"1.5.1","depth":2,"path":"balance_sheet.md","ref":"balance_sheet.md","articles":[]},{"title":"deriv_finance_indicator","level":"1.5.2","depth":2,"path":"deriv_finance_indicator.md","ref":"deriv_finance_indicator.md","articles":[]},{"title":"fundamentals_balance","level":"1.5.3","depth":2,"path":"fundamentals_balance.md","ref":"fundamentals_balance.md","articles":[]},{"title":"fundamentals_cashflow","level":"1.5.4","depth":2,"path":"fundamentals_cashflow.md","ref":"fundamentals_cashflow.md","articles":[]},{"title":"fundamentals_income","level":"1.5.5","depth":2,"path":"fundamentals_income.md","ref":"fundamentals_income.md","articles":[]},{"title":"share_change","level":"1.5.6","depth":2,"path":"share_change.md","ref":"share_change.md","articles":[]},{"title":"trading_derivative_indicator","level":"1.5.7","depth":2,"path":"trading_derivative_indicator.md","ref":"trading_derivative_indicator.md","articles":[]}]},"previous":{"title":"函数及常量","level":"1.3","depth":1,"path":"函数及常量.md","ref":"函数及常量.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"BARRA因子.md","mtime":"2023-06-02T03:16:46.963Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-07-01T05:15:14.464Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

